package com.ruoyi.labdanger.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labdanger.domain.LabApplyOccupationDeliver;
import com.ruoyi.labdanger.service.ILabApplyOccupationDeliverService;


/**
 * 申领出库Controller
 *
 * @author ruoyi
 * @date 2022-03-22
 */
@RestController
@RequestMapping("/system/deliver")
public class LabApplyOccupationDeliverController extends BaseController {
    @Autowired
    private ILabApplyOccupationDeliverService labApplyOccupationDeliverService;

    /**
     * 查询申领出库列表
     */
    @PreAuthorize("@ss.hasPermi('system:deliver:query')")
    @GetMapping("/list")
    public TableDataInfo list(LabApplyOccupationDeliver labApplyOccupationDeliver) {
        startPage();
        List<LabApplyOccupationDeliver> list = labApplyOccupationDeliverService.selectLabApplyOccupationDeliverList(labApplyOccupationDeliver);
        return getDataTable(list);
    }

    /**
     * 导出申领出库列表
     */
    /*@PreAuthorize("@ss.hasPermi('system:deliver:export')")
    @Log(title = "申领出库", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabApplyOccupationDeliver labApplyOccupationDeliver) {
        List<LabApplyOccupationDeliver> list = labApplyOccupationDeliverService.selectLabApplyOccupationDeliverList(labApplyOccupationDeliver);
        ExcelUtil<LabApplyOccupationDeliver> util = new ExcelUtil<LabApplyOccupationDeliver>(LabApplyOccupationDeliver.class);
        return util.exportExcel(list, "deliver");
    }*/

    /**
     * 获取申领出库详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:deliver:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(labApplyOccupationDeliverService.selectLabApplyOccupationDeliverById(id));
    }

    /**
     * 新增申领出库
     */
    @PreAuthorize("@ss.hasPermi('system:deliver:edit')")
    @Log(title = "申领出库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabApplyOccupationDeliver labApplyOccupationDeliver) {
        return toAjax(labApplyOccupationDeliverService.insertLabApplyOccupationDeliver(labApplyOccupationDeliver));
    }

    /**
     * 修改申领出库
     */
    @PreAuthorize("@ss.hasPermi('system:deliver:edit')")
    @Log(title = "申领出库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabApplyOccupationDeliver labApplyOccupationDeliver) {
        return toAjax(labApplyOccupationDeliverService.updateLabApplyOccupationDeliver(labApplyOccupationDeliver));
    }

    /**
     * 删除申领出库
     */
    @PreAuthorize("@ss.hasPermi('system:deliver:edit')")
    @Log(title = "申领出库", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(labApplyOccupationDeliverService.deleteLabApplyOccupationDeliverByIds(ids));
    }
}
